<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
    />
    <meta name="author" content="林镭特" />
    <title></title>
   
    <style>
      div {
        display: none;
        width: 80px;
        height: 100px;
        border: 1px solid #a3a3ff;
        color: #a3a3ff;
      }
      p{
          cursor: pointer;
          margin-top: 5px;
      }
    </style>
  </head>
  <body>
    <!-- 百度输入法 -->
    <main>
      <button>输入法</button>
      <div>
        <p>手写</p>
        <p>拼音</p>
        <p>关闭</p>
      </div>
    </main>
    <script>
      var main = document.querySelector("main");
      var button = document.querySelector("button");
      var div = document.querySelector("div");
      main.appendChild(div);

      button.onclick = function() {
        if (div.style.display == "block") {
          div.style.display = "none";
        } else {
          div.style.display = "block";
        }
      };
      var p = document.querySelectorAll("p");
      for (var i = 0; i < 3; i++) {
        p[i].onclick = function() {
          if (div.style.display == "block") {
            div.style.display = "none";
          } else {
            div.style.display = "block";
          }
        };
      }
    </script>
  </body>
</html>
